package com.tyf.common.web.utils;

import com.google.common.collect.Maps;
import com.tyf.common.vo.ResultVO;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * Created by tyf on 2018/1/17
 */
public class WebUtils {

    private WebUtils() {}

    /**
     * 获取默认的resultMap
     * @return
     */
    public static Map<String, Object> getDefaultResultMap(){
        Map<String, Object> resultMap = Maps.newHashMap();
        ResultVO flag = new ResultVO();

        resultMap.put("flag", flag);
        return resultMap;
    }

    public static Map<String,Object> getErrorResultMap(String errCode,String retMsg,String detailMessage){
        Map<String, Object> resultMap = Maps.newHashMap();
        ResultVO flag = new ResultVO();
        flag.setRetCode(errCode);
        if(StringUtils.isNotBlank(retMsg))
            flag.setRetMsg(retMsg);
        if(StringUtils.isNotBlank(detailMessage))
            flag.setRetDetail(detailMessage);

        resultMap.put("flag", flag);
        return resultMap;
    }

}